<div class="pop-box">
    <div class="head clearfix">
        <a href="javascript:void(0);" class="iconfont icon-zuo hide"></a>
        <span class="head-name">搜索</span>
        <a href="javascript:void(0);" class="text-right sure">确定</a>
    </div>
    <div class="lists" style="border: none;">会议室区域:</div>

    <div class="form-box" style="margin-top: 0;">
        <p class="form-list clearfix" style="border: none">
            <select name="area" id="area" class="text-12" style="width: 100%;margin-bottom: 10px">
                <option value="0">请选择一级区域</option>
            </select>
            <select name="building" id="building" class="text-12" style="width: 100%;">
                <option value="0">请选择二级区域</option>
            </select>
        </p>
    </div>
    <!--<div class="lists" style="border: none;">
        <p class="title">会议室类型:</p>
        <div class="label-box text-12 clearfix type">
            <a href="javascript:void(0)" class="label actived" data-meeting_room_style_id="0">全部</a>
            <foreach name="roomStyle" item="vo" key="k">
                <a href="javascript:void(0)" class="label" data-meeting_room_style_id="{BEESCRM:$vo.meeting_room_style_id}">{BEESCRM:$vo.style_name}</a>
            </foreach>
        </div>
    </div>-->
</div>


<script>
    $(document).on('click','.hide',function() {
        $(".pop-box").hide();
    })

    $(document).on('click','.filter',function() {
        $.ajax({
            url : '/meeting/MeetingRoom/doGetArea/account_id/{BEESCRM:$accountId}',
            type : 'post',
            data : {},
            dataType : 'json',
            success : function (result) {
                var html = '<option value="0">请选择一级区域</option>';
                if(result.status == 'S'){
                    $.each(result.message, function(key, value){
                        html += '<option value="'+ value.meeting_room_area_id +'">' + value.area_name + '</option>';
                    });
                    $("#area").html(html);
                }else if(result.status == 'F'){
                    $("#area").html(html);
                }
            }
        });
        $('.pop-box').show();
    })

    //区域联动
    $("#area").change(function () {
        var area_id = $(this).val();
        if(area_id == 0){
            return;
        }else{
            $.ajax({
                url : '/meeting/MeetingRoom/doGetBuilding/account_id/{BEESCRM:$accountId}',
                type : 'post',
                data : {area_id : area_id},
                dataType : 'json',
                success : function (result) {
                    var html = '<option value="0">请选择二级区域</option>';
                    if(result.status == 'S'){
                        $.each(result.message, function(key, value){
                            html += '<option value="'+ value.meeting_building_id +'">' + value.building_name + '</option>';
                        });
                        $("#building").html(html);
                    }else if(result.status == 'F'){
                        $("#building").html(html);
                    }
                }
            })
        }
    })

    $(document).on('click','.sure',function() { //确定
        var data = {};
        //var time = $("#time").val();  //预约日期
        data.room_name = $("input[name='room_name']").val();
        data.meeting_room_style_id = $(".type .actived").data('meeting_room_style_id');
//        data.meeting_room_area_id = $(".area .actived").data('meeting_room_area_id');
        data.meeting_room_area_id = $("#area").val();
        data.building_id = $("#building").val();

        var account_id = $(".filter").data('account_id');
        var url = '/meeting/meetingOutDoor/doorList/account_id/'+account_id;
        if(data.room_name) {
            url = url + '/room_name/'+ data.room_name;
        }
        if(data.meeting_room_style_id) {
            url = url + "/meeting_room_style_id/"+data.meeting_room_style_id;
        }
        if(data.meeting_room_area_id) {
            url = url + '/meeting_room_area_id/'+data.meeting_room_area_id;
        }
        if(data.building_id){
            url = url + '/building_id/' + data.building_id;
        }
        location.href = url;
    })

    $(".type a.label").click(function(){
        $(this).addClass('actived').siblings().removeClass('actived');
    });

    $(".area a.label").click(function(){
        $(this).addClass('actived').siblings().removeClass('actived');
    });
</script>